import 'package:flutter/material.dart';

///点击事件
class ClickDemo extends StatelessWidget {
  final String title;

  const ClickDemo({Key? key, required this.title}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("$title"),
        centerTitle: true,
      ),
      body: ClickWidget(),
    );
  }
}

class ClickWidget extends StatelessWidget {
  const ClickWidget({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Center(
      child: GestureDetector(
        //点击事件
        onTap: () {
          print("single onClick");
        },
        //双击事件
        onDoubleTap: () {
          print("double onClick");
        },
        child: Text(
          "单击/双击",
          style: TextStyle(fontSize: 20, color: Colors.blue),
        ),
      ),
    );
  }
}
